home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2001 May / SGI IRIX Base Documentation 2001 May.iso / usr / share / catman / p_man / cat3 / perl5 / Config.z / Config
Encoding:
Text File  |  1998-10-30  |  3.5 KB  |  133 lines

  1.  
  2.  
  3.  
  4. CCCCoooonnnnffffiiiigggg((((3333))))                                                            CCCCoooonnnnffffiiiigggg((((3333))))
  5.  
  6.  
  7.  
  8. NNNNAAAAMMMMEEEE
  9.      Config - access Perl configuration information
  10.  
  11. SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  12.          use Config;
  13.          if ($Config{'cc'} =~ /gcc/) {
  14.              print "built by gcc\n";
  15.          }
  16.  
  17.          use Config qw(myconfig config_sh config_vars);
  18.  
  19.          print myconfig();
  20.  
  21.          print config_sh();
  22.  
  23.          config_vars(qw(osname archname));
  24.  
  25.  
  26. DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  27.      The Config module contains all the information that was available to the
  28.      Configure program at Perl build time (over 900 values).
  29.  
  30.      Shell variables from the _c_o_n_f_i_g._s_h file (written by Configure) are stored
  31.      in the readonly-variable %Config, indexed by their names.
  32.  
  33.      Values stored in config.sh as 'undef' are returned as undefined values.
  34.      The perl exists function can be used to check if a named variable exists.
  35.  
  36.      myconfig()
  37.          Returns a textual summary of the major perl configuration values.
  38.          See also -V in the Switches entry in the _p_e_r_l_r_u_n manpage.
  39.  
  40.      config_sh()
  41.          Returns the entire perl configuration information in the form of the
  42.          original config.sh shell variable assignment script.
  43.  
  44.      config_vars(@names)
  45.          Prints to STDOUT the values of the named configuration variable. Each
  46.          is printed on a separate line in the form:
  47.  
  48.            name='value';
  49.  
  50.          Names which are unknown are output as name='UNKNOWN';.  See also
  51.          -V:name in the Switches entry in the _p_e_r_l_r_u_n manpage.
  52.  
  53. EEEEXXXXAAAAMMMMPPPPLLLLEEEE
  54.      Here's a more sophisticated example of using %Config:
  55.  
  56.          use Config;
  57.          use strict;
  58.  
  59.  
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. CCCCoooonnnnffffiiiigggg((((3333))))                                                            CCCCoooonnnnffffiiiigggg((((3333))))
  71.  
  72.  
  73.  
  74.          my %sig_num;
  75.          my @sig_name;
  76.          unless($Config{sig_name} && $Config{sig_num}) {
  77.              die "No sigs?";
  78.          } else {
  79.              my @names = split ' ', $Config{sig_name};
  80.              @sig_num{@names} = split ' ', $Config{sig_num};
  81.              foreach (@names) {
  82.                  $sig_name[$sig_num{$_}] ||= $_;
  83.              }
  84.          }
  85.  
  86.          print "signal #17 = $sig_name[17]\n";
  87.          if ($sig_num{ALRM}) {
  88.              print "SIGALRM is $sig_num{ALRM}\n";
  89.          }
  90.  
  91.  
  92. WWWWAAAARRRRNNNNIIIINNNNGGGG
  93.      Because this information is not stored within the perl executable itself
  94.      it is possible (but unlikely) that the information does not relate to the
  95.      actual perl binary which is being used to access it.
  96.  
  97.      The Config module is installed into the architecture and version specific
  98.      library directory ($Config{installarchlib}) and it checks the perl
  99.      version number when loaded.
  100.  
  101. NNNNOOOOTTTTEEEE
  102.      This module contains a good example of how to use tie to implement a
  103.      cache and an example of how to make a tied variable readonly to those
  104.      outside of it.
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.                                                                         PPPPaaaaggggeeee 2222
  130.  
  131.  
  132.  
  133.